from race.Player import *
import logging.config
from threading import Thread

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")


class DhTank(Player):
    def a(self):

        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        #self.startScheduler3()  # 调用 CallBackScheduler3
        self.startScheduler4()  # 调用 CallBackScheduler4
        self.startScheduler5()  # 调用 CallBackScheduler5
        return

    def CallBackScheduler1(self):

        while self.ui.stopLoop == False:
            # # 裂魂，产生紫色的点.(技能CD，不要多按)
            # self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X7, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
            #                                 self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 'r', 'big', '1', 0.06, 2,'1')

            # 减伤分配机制，不要多个减伤重，平均分配
            # 烈火烙印(技能CD，不要多按)
            self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X4, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                            self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '7', 0.06, 2, '1')

            # # 大碰(血条低于多少，必然触发)
            # self.pubAvgColorTiggerKeyBloodBarMode(546, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                       self.WABloodBarAvgColor, 'r', 'small', '2', 0.06, 2,'1')

            # 饰品(血条低于多少，必然触发)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, '8', 'small', 'l', 0.06, 2, '1')

            # 术士治疗石(血条低于多少，必然触发)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.5, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'n', 'small', 'l', 0.06, 2, '1')

            # 变恶魔(血条低于多少，必然触发)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.4, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 't', 'small', 'l', 0.06, 2, '1')

            # 格里恩血瓶(血条低于多少，必然触发)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'i', 'small', 'l', 0.06, 2, '1')

            # 痛苦咒符（和减伤搭上关系）
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', 'k', 0.06, 2, '1')

            # 群拉。投掷利刃(技能CD，不要多按)
            self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X8, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                            self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '3', 0.06, 2, '1')

            # 积累恶魔之怒，献祭光环(技能CD，不要多按)
            self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X6, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                            self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '4', 0.06, 2, '1')

            # 格里恩图腾，极乐赦令(技能CD，不要多按)
            self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X3, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                            self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '5', 0.06, 2, '1')

            # 烈焰咒符(技能CD，不要多按)
            self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X5, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                            self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '9', 0.06, 2, '1')

    def CallBackScheduler2(self):
        # 并发执行
        while self.ui.stopLoop == False:
            # 尖刺减伤(血条低于多少，必然触发)(避免尖刺多开)
            # self.pubAvgColorTiggerKeyBloodBarMode(546, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                       self.WABloodBarAvgColor, 'r', 'small', '8', 0.06, 2,'1')
            self.pubAvgColorTiggerKeyAndStopClickTwice(self.WABloodBarX + self.WABloodBarWidth * 0.8, self.WABloodBarY,
                                                       self.WABloodBarDeltaX,
                                                       self.WABloodBarDeltaY, self.WABloodBarAvgColor, 'r', 'small',
                                                       '8', 0.06, 2, self.WA_SQUARE_ZFX_X2, self.WA_SQUARE_ZFX,
                                                       self.WABloodBarDeltaX,
                                                       self.WABloodBarDeltaY, 'r', 0, 'small', '1')
            # 尖刺减伤(血条低于多少，必然触发)，危险，全部放出去
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.5, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, '8', 'small', 'l', 0.06, 2, '1')
            sleep(0.1)

    def CallBackScheduler3(self):
        # 并发执行
        while self.ui.stopLoop == False:
            sleep(0.2)

    def CallBackScheduler4(self):
        # 并发执行
        while self.ui.stopLoop == False:
            # 裂魂，产生紫色的点.(技能CD，不要多按)
            # self.pubAvgColorTiggerKeyCDMode(193, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 'r', 'big', '1', 0.06, 2,'1')
            # # 大喷(血条低于多少，必然触发)
            # self.pubAvgColorTiggerKeyBloodBarMode(548, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                       self.WABloodBarAvgColor, 'r', 'small', '2', 0.06, 1,'1')
            # 大喷(CD不要多按)
            # pubAvgColorNoTrigger
            avgColor1 = self.pubAvgColorNoTrigger(self.WABloodBarX + self.WABloodBarWidth - 16, self.WABloodBarY - 4, 5,
                                                  5,
                                                  'r', 0)
            if avgColor1 < self.WABloodBarAvgColor:
                # 满血不碰
                self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                                self.WABloodBarDeltaY,
                                                self.WA_SQUARE_ZFX_AvgColor,
                                                'r', 'big', '2', 0.06, 2, '1')
            sleep(0.2)

    def CallBackScheduler5(self):
        while self.ui.stopLoop == False:
            # 裂魂
            self.click(self.kb, '1', 3)
            sleep(0.1)

            # 幽魂炸弹
            self.click(self.kb, '6', 3)
            sleep(0.1)

            # 献祭光环
            self.click(self.kb, '4', 3)
            sleep(0.1)

    def on_mouse_click_son_before_thread(self, x, y, button, pressed):
        # self.interruptAllByForce()
        pass
        return

    def x(self):
        for i in range(1, 4):
            self.click(self.kb, ']', 2)
            sleep(0.1)

        # 打断后的继续
        self.click(self.kb, 'a', 1)
        return

    def mouseUp(self, x, y):
        # 手工补尖刺
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        for i in range(1, 4):
            self.click(self.kb, '8', 2)
            sleep(0.1)
        log.debug('★鼠标向上滚，需要over执行的内容★')
        return

    def mouseDown(self, x, y):
        # 手工开T的防护恶魔大招
        for i in range(1, 6):
            self.click(self.kb, 't', 2)
            sleep(0.1)
        return

    def w(self):
        for i in range(1, 6):
            self.click(self.kb, 't', 2)
            sleep(0.1)
        return

    def q(self):
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        for i in range(1, 4):
            self.click(self.kb, '8', 2)
            sleep(0.1)
        log.debug('★鼠标向上滚，需要over执行的内容★')
        return


class DhDPS(Player):
    def a(self):
        while self.ui.stopLoop == False:
            self.click(self.kb, '1', 2)
            sleep(0.1)
            self.click(self.kb, '2', 2)
            sleep(0.1)
            self.click(self.kb, '3', 2)
            sleep(0.1)
            self.click(self.kb, '4', 2)
